package com.andaily.domain.dto.thing;

import com.andaily.domain.shared.paginated.DefaultPaginated;
import com.andaily.domain.shared.security.SecurityUtils;
import com.andaily.domain.thing.ThingStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Shengzhao Li
 * @see com.andaily.domain.thing.Thing
 */
public class ThingMonitoringDto extends DefaultPaginated<ThingDto> {


    private ThingStatus status = ThingStatus.PENDING;
    private boolean showMore;

    public ThingMonitoringDto() {
    }

    public Map<String, Object> params() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userGuid", SecurityUtils.currentUserGuid());
        map.put("perPageSize", getPerPageSize());
        map.put("startIndex", getStartIndex());
        map.put("status", status);
        return map;
    }

    public void afterLoad() {
        this.showMore = isHasNext();
    }

    public boolean isPending() {
        return ThingStatus.PENDING.equals(status);
    }

    public boolean isCreated() {
        return ThingStatus.CREATED.equals(status);
    }

    public boolean isShowMore() {
        return showMore;
    }

    public void setShowMore(boolean showMore) {
        this.showMore = showMore;
    }

    public ThingStatus getStatus() {
        return status;
    }

    public void setStatus(ThingStatus status) {
        this.status = status;
    }
}
